<template>
  <div class="chat-input">
    <textarea
        v-model="inputText"
        @keydown.enter.exact.prevent="sendMessage"
        placeholder="输入消息..."
        class="input-field"
        rows="3"
    ></textarea>
    <button @click="sendMessage" class="send-button">发送</button>
  </div>
</template>

<script setup>
import {ref} from 'vue';

const inputText = ref('');
const emit = defineEmits(['send']);

// 发送消息
const sendMessage = () => {
  if (inputText.value.trim()) {
    emit('send', inputText.value);
    inputText.value = '';
  }
};
</script>

<style scoped>
/* 输入框区域样式 */
.chat-input {
  display: flex;
  padding: 16px;
  background: #ffffff;
  border-top: 1px solid #e0e0e0;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  margin: 16px;
}

/* 输入框样式 */
.input-field {
  flex: 1;
  padding: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  background: #f9f9f9;
  color: #333;
  outline: none;
  font-size: 14px;
  resize: none;
  font-family: Arial, sans-serif;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-field:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

/* 发送按钮样式 */
.send-button {
  margin-left: 12px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #007bff, #00ccff);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.send-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.send-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
</style>